'''
Created on Mar 7, 2016

@author: JimmyMo
'''
from reader.perfsynreader import Reader
import random
class Reader4Generator(Reader):
    def _parse_options(self):
        self.device_num = 3000
        self.port_num = 100
        pass
    def __init__(self):
        super().__init__()
        pass
    def _read(self):
        logs4all_devices = []
        print("generating logs4device...")
        for i in range(self.device_num):
            # print("generating logs for device #%d" % i)
            logs4device = self.__get_device_log("devicename%d" % i, self.port_num)
#             logs4all_devices.append(logs4device)
            logs4all_devices = logs4all_devices + logs4device
        print("end generating...")
        print("writing logs4device...")
        return logs4all_devices
    
    def __get_device_log(self, device_name, port_num):
        counter = 1
    
        logs4device = []
        logs4device.append({
                     "devicename": device_name,
                     "cpu": random.randint(1, 100),
                     "mem": random.randint(1, 2048)
                     })
        for i in range(port_num):
            counter = counter + 1
            port_name = "Gi3/1/%d" % i
            inbound = random.randint(1000000, 2000000)
            outbound = random.randint(1000000, 2000000)
            active_con = random.randint(1, 1000)
            current_con = random.randint(1, 1000)
            total_session = random.randint(1, 10000)
            logs4device.append({
    #                    "_id": str(counter),
                         "devicename": device_name,
                         "portname": port_name,
                         "inbound": inbound,
                         "outbound": outbound,
                         "active_con": active_con,
                         "current_con": current_con,
                         "total_session": total_session      
                         })
        
        return logs4device
